import useUpload from './hooks/useUpload'
import { FileConfType } from './configType'
const { onBeforeUpload, uploadHandler, uploadFetch, getAttachmentUrl } =
  useUpload()

// const BASE_URL = import.meta.env.BASE_URL
const BASE_URL = ''

export const editorConfig = {
  language_url: `${BASE_URL}/resource/tinymce/zh_CN.js`, //指定中文包
  language: `${BASE_URL}zh_CN`, //中文

  toolbar_mode: 'wrap',
  menubar: false,
  file_picker_types: 'file',
  paste_data_images: true,
  toolbar_sticky: false,
  toolbar_groups: {
    formatting: {
      text: '文字格式',
      tooltip: 'Formatting',
      items: 'bold italic underline | superscript subscript'
    },
    alignment: {
      icon: 'align-left',
      tooltip: 'alignment',
      items: 'alignleft aligncenter alignright alignjustify'
    }
  },

  content_style: 'p {margin: 5px 0;}',
  fontsize_formats: '12px 14px 16px 18px 24px 36px 48px 56px 72px',
  font_formats:
    '微软雅黑=Microsoft YaHei,Helvetica Neue,PingFang SC,sans-serif;苹果苹方=PingFang SC,Microsoft YaHei,sans-serif;宋体=simsun,serif;仿宋体=FangSong,serif;黑体=SimHei,sans-serif;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;',
  branding: false,

  end_container_on_empty_block: true,
  powerpaste_word_import: 'clean',
  code_dialog_height: 450,
  code_dialog_width: 1000,
  advlist_bullet_styles: 'square',
  advlist_number_styles: 'default',
  imagetools_cors_hosts: ['www.tinymce.com', 'codepen.io'],
  default_link_target: '_blank',
  link_title: false,
  nonbreaking_force_tab: true,

  convert_urls: false
}

export const imageConfig: FileConfType = {
  name: '图片',
  fieldName: 'file',
  allowedFileTypes: ['*'],
  maxFileSize: 20 * 1024 * 1024,
  server: '/biz/plan/uploadFile',
  attachmentServer: '/biz/plan/getAttachmentUrl',
  headers: {},
  onBeforeUpload,
  uploadFetch,
  getAttachmentUrl,
  uploadHandler
}

export const attachmentConfig: FileConfType = {
  name: '附件',
  fieldName: 'file',
  allowedFileTypes: ['.word', '.pdf'],
  maxFileSize: 20 * 1024 * 1024,
  server: '/biz/plan/uploadFile',
  attachmentServer: '/biz/plan/getAttachmentUrl',
  headers: {},
  onBeforeUpload,
  uploadFetch,
  getAttachmentUrl,
  uploadHandler
}

export const lightCss = {
  skin_url: `${BASE_URL}/resource/tinymce/skins/ui/oxide`, //编辑器皮肤，
  content_css: `${BASE_URL}/resource/tinymce/skins/content/default/content.css`
}

export const darkCss = {
  skin_url: `${BASE_URL}/resource/tinymce/skins/ui/oxide-dark`, //编辑器皮肤，
  content_css: `${BASE_URL}/resource/tinymce/skins/content/dark/content.css`
}
